package com.uobgroup.ews.uam.core.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.beans.factory.annotation.Configurable;

@Configurable
@Entity
@NamedQueries({ @NamedQuery(name = "Segment.findAllSecurityGroupsThatHasNoSegment", query = "SELECT S FROM SecurityGroup S WHERE S.id NOT IN (SELECT SGM.securityGroup.id FROM Segment SGM)") })
public class SecurityGroup extends BaseEntity {

   public static final String QUERY_FIND_SECURITYGROUPS_THAT_HAS_NO_SEGMENT = "Segment.findAllSecurityGroupsThatHasNoSegment";

   @Size(max = 1000)
   private String description;

   @NotNull
   @Size(max = 1000)
   private String displayName;

   @NotNull
   @Size(max = 255)
   private String DN;

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id")
   private Long id;

   @OneToOne(mappedBy = "securityGroup")
   private UAMRole uamRole;

   @OneToOne(mappedBy = "securityGroup", cascade = CascadeType.ALL)
   private Segment segment;

   @OneToOne(mappedBy = "securityGroup")
   private Profile profile;

   @OneToOne(mappedBy = "securityGroup")
   private AccessToStaff accessToStaff;

   @OneToOne(mappedBy = "securityGroup")
   private CombinationACL combinationACL;

   public CombinationACL getCombinationACL() {
      return combinationACL;
   }

   public void setCombinationACL(CombinationACL combinationACL) {
      this.combinationACL = combinationACL;
   }

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String getDescription() {
      return this.description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public String getDisplayName() {
      return this.displayName;
   }

   public void setDisplayName(String displayName) {
      this.displayName = displayName;
   }

   public String getDN() {
      return this.DN;
   }

   public void setDN(String DN) {
      this.DN = DN;
   }

   public UAMRole getUamRole() {
      return uamRole;
   }

   public void setUamRole(UAMRole uamRole) {
      this.uamRole = uamRole;
   }

   public Segment getSegment() {
      return segment;
   }

   public void setSegment(Segment segment) {
      this.segment = segment;
   }

   public AccessToStaff getAccessToStaff() {
      return accessToStaff;
   }

   public void setAccessToStaff(AccessToStaff accessToStaff) {
      this.accessToStaff = accessToStaff;
   }

   public Profile getProfile() {
      return profile;
   }

   public void setProfile(Profile profile) {
      this.profile = profile;
   }
}
